﻿CREATE TABLE [CO].[Departments] (
    [Id]               INT            NOT NULL,
    [Name]             VARCHAR (100)  NOT NULL,
    [ShortName]        VARCHAR (20)   NOT NULL,
    [DeliveryDuration] TINYINT        DEFAULT ((0)) NOT NULL,
    [Note]             VARCHAR (250)  NULL,
    [MD]               DATETIME       CONSTRAINT [DF__Departments__MD__78D3EB5B] DEFAULT (getdate()) NOT NULL,
    [MW]               VARCHAR (50)   CONSTRAINT [DF__Departments__MW__79C80F94] DEFAULT (suser_sname()) NOT NULL,
    [ToDelete]         BIT            DEFAULT ((0)) NOT NULL,
    [SyncHostName]     NVARCHAR (150) NULL,
    CONSTRAINT [PK_Departments] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Departments_Name]
    ON [CO].[Departments]([Name] ASC);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Departments_ShortName]
    ON [CO].[Departments]([ShortName] ASC);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Время доставки товаров (дн. - для расчета дефектуры)', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'Departments', @level2type = N'COLUMN', @level2name = N'DeliveryDuration';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Признак того, что запись нужно удалить из БД всех подразделений', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'Departments', @level2type = N'COLUMN', @level2name = N'ToDelete';

